package org.iteam.bank.signed.service;

import java.sql.SQLException;
import java.util.List;

import org.iteam.bank.core.Constant;
import org.iteam.bank.signed.model.Bank;
import org.iteam.bank.signed.model.BankCardBin;
import org.iteam.db.SimpleDbRunner;
import org.iteam.db.exception.DbException;

/**
 * 银行卡饼service
 * 
 * @author admin
 *
 */
public class BankCardBinService {
	public static BankCardBinService getInstance() {
		return Subclass.service;
	}

	private static final class Subclass {
		public static final BankCardBinService service = new BankCardBinService();
	}

	private BankCardBinService() {
		super();
	}

	public List<Bank> queryAll() throws DbException {
		String sql = "select * from banks where status = 0 order by seq desc ";
		return new SimpleDbRunner(Constant.MYSQL_WEIXIN).findBeanList(Bank.class, sql);
	}

	/**
	 * 查询银行卡类型
	 * 
	 * @param card_flag
	 * @return
	 * @throws SQLException
	 */
	public BankCardBin showByCardFlag(String card_flag) throws DbException {
		String sql = "select * from bank_card_bin where card_flag = ? ";
		return new SimpleDbRunner(Constant.MYSQL_WEIXIN).findBeanOne(BankCardBin.class, sql, card_flag);
	}
}
